package com.afs.electronicforensics.monitor;

import android.graphics.Color;
import android.text.Editable;
import android.text.TextWatcher;
import android.widget.EditText;
import android.widget.TextView;

import com.afs.electronicforensics.activity.R;
import com.afs.electronicforensics.adapter.AlbumCloudAdapter;

public class FileModMonitorEditText implements TextWatcher {
    private TextView textView;
    private EditText name;
    private EditText remark;
    private String oldName;
    private String oldRemark;

    public void SetMonitorEditText(TextView textView,
                                   EditText name,EditText remark,
                                   String oldName, String oldRemark) {

        this.textView = textView;
        this.name = name;
        this.remark = remark;
        this.oldName = oldName;
        this.oldRemark = oldRemark;

        name.addTextChangedListener(FileModMonitorEditText.this);
        remark.addTextChangedListener(FileModMonitorEditText.this);
    }

    @Override
    public void beforeTextChanged(CharSequence s, int start, int count,
                                  int after) {
        // TODO Auto-generated method stub

    }
    @Override
    public void onTextChanged(CharSequence s, int start, int before, int count) {
    }

    @Override
    public void afterTextChanged(Editable s) {
        // TODO Auto-generated method stub
        if (name.length() != 0 && remark.length() != 0){
            if (name.getText().toString().trim().equals(oldName) && remark.getText().toString().trim().equals(oldRemark)){
                textView.setTextColor(Color.parseColor("#AAAAAA"));
                textView.setEnabled(false);
                return;
            }else {
                textView.setTextColor(Color.parseColor("#88BEF5"));
                textView.setEnabled(true);
            }
        }else{
            textView.setTextColor(Color.parseColor("#AAAAAA"));
            textView.setEnabled(false);
            return;
        }
    }
}